const db =wx.cloud.database()
const newsSchool1 =db.collection('newsSchool1')
Page({

    data: {
      newsSchool1:[],
      //滑块新闻展示
      imgUrls: [
        'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1545220114942&di=3bf52981626b3cc290dd684df29e714c&imgtype=0&src=http%3A%2F%2Fimgsrc.baidu.com%2Fimgad%2Fpic%2Fitem%2F8b82b9014a90f6038de2556a3212b31bb051ed4a.jpg',
        'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1545220114942&di=3bf52981626b3cc290dd684df29e714c&imgtype=0&src=http%3A%2F%2Fimgsrc.baidu.com%2Fimgad%2Fpic%2Fitem%2F8b82b9014a90f6038de2556a3212b31bb051ed4a.jpg',
        'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1545220114942&di=3bf52981626b3cc290dd684df29e714c&imgtype=0&src=http%3A%2F%2Fimgsrc.baidu.com%2Fimgad%2Fpic%2Fitem%2F8b82b9014a90f6038de2556a3212b31bb051ed4a.jpg'
      ],
      interval: 5000,
      duration: 1000,
      circular: true,
      leftMargin: '80rpx',
      rightMargin: '80rpx',
      currentIndex: 0,

      //列表新闻展示
      newsList: [{
        id: '264698',
        title: '俄罗斯联邦驻华大使杰尼索夫会见校党委书记顾家山一行并接受《力冈译文全集》赠予',
        poster: 'https://img-blog.csdnimg.cn/20200401212701440.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80NTg2MzkyMQ==,size_16,color_FFFFFF,t_70',
        add_date: '2018-03-05'
      }]
    },
    handleChange: function (e) {
      this.setData({
        currentIndex: e.detail.current
      })
    },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    newsSchool1.get().then(res=>{
      console.log(res.data)
      this.setData({
        newsSchool1:res.data
      })
    })
    wx.request({
      url: 'https://free-api.heweather.net/s6/weather/now?location=常州&key=00d5bcd4012941db939bd2d1f74c994a', 
      header: {
        'content-type': 'application/json' // 默认值
      },success:res=>{
        console.log('网络请求成功之后获取到的数据', res)
        console.log('和风天气api', res.data)
        let weather=res.data.HeWeather6[0]
        console.log(weather)
         this.setData({
          weather:res.data.HeWeather6[0]
        })
      }
    })
  },
  onSwiper:function(e){
    var newsid=e.currentTarget.dataset.id;
    console.log(newsid)
    wx.navigateTo({
      url: '../news/news2/news2?id='+newsid,
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
    
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
    
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    
  },
  indexNews:function(e){
    wx.navigateTo({
      url: '../news/news',
    })
  },
  indexNewStart:function(e){
    wx.navigateTo({
      url: '../newStart/newStart',
    })
  },
  indexSub:function(e){
    wx.navigateTo({
      url: '../requestSubscribe/requestSubscribe',
    })
  },
  indexFind:function(e){
    wx.navigateTo({
      url: '../findLost/findLost',
    })
  },
  indexMess:function(e){
    wx.navigateTo({
      url: '../message/message',
    })
  }

})